<%@page contentType="text/html; charset=utf-8" language="java"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>用户信息管理</title>
	<jsp:include page="/common/header-common.jsp"></jsp:include>
	<script type="text/javascript">
	function update(id) {
		location.href="userAdd.action?id="+id;
	}
	function deleteId(id) {
		if(confirm("确定要删除ID号为：\n"+id+"\n的用户？？")){
			location.href="userQuery!delete.action?deleteIds="+id;
		}
	}
	
	//=================删除====================
		function deleteArticles(){
			var mtable=document.getElementById('listTable');
			var singleboxs = document.getElementsByName("singleBox");
			var number=0;
			for(var i=1;i<=singleboxs.length;i++){
				if(mtable.rows[i].cells[0].firstChild.checked)
					number++;
			}
			if(number==0)
				alert("请先选择要删除的用户");
			else{
				var j=0;
				articleIds=new Array; 
				for(var i=0;i<singleboxs.length;i++){
					if(singleboxs[i].checked){
						articleIds[j]=singleboxs[i].value;
						j++;
					}
				}
				var deleteArticles='';
				var message='';
				for(var i=0;i<articleIds.length;i++){
					if(i<articleIds.length-1){
						deleteArticles=deleteArticles+articleIds[i]+',';
						message=message+articleIds[i]+'\n';
					}
					else{
						deleteArticles=deleteArticles+articleIds[i];
						message=message+articleIds[i];	
					}
				}
				if(confirm("确定要删除ID号为：\n"+message+"\n的用户？？")){
					location.href="deviceQuery!delete.action?deleteIds="+deleteArticles;
				}
			}
		}
	function selectAll(obj){
		var singleboxs = document.getElementsByName("singleBox");
		if(obj.checked){
			for(var i=0;i<singleboxs.length;i++)
				singleboxs[i].checked=true;
		}else{
			for(var i=0;i<singleboxs.length;i++)
				singleboxs[i].checked=false;
		}
	}
	function goUrl(pageIndex){
		searchFrm.currPage.value = pageIndex;
		searchFrm.submit();
	}
	</script>
</head>
	<body id="userquery">
	<div id="aaaa" style="position: absolute;top: 0px; left: 0px;"></div>
		<div id="wrapper">
			<s:include value="/common/header.jsp"></s:include>
			<form id="searchFrm" name="searchFrm" method="post" action="userQuery.action">
			<input type="hidden" name="currPage" value="0" />
			<jsp:include page="navication.jsp"></jsp:include>
			<div id="rss_content">
				<div class="rss_title">用户信息管理</div>
				<div class="rss_description">您在这里查看的是用户信息</div>
				<s:if test="message != null">
					<div class="return_tip">
						<s:property value="message" />
					</div>
				</s:if>
				<table width="98%" border="0" cellpadding="1" cellspacing="5" class="tab_1">
							<tr align="left">
								<td height="40">
									&nbsp;用户名：
									<input type="text" name="username" size="20" value='<s:property value="username"/>'/>
									&nbsp;级别：
									<s:select list="#{'':'','1':'普通用户','2':'分公司用户','3':'总公司用户'}" value="level" name="level" theme="simple"></s:select>
									&nbsp;状态：
									<s:select list="#{true:'启用',false:'删除'}" value="enable" name="enable" theme="simple"></s:select>
									<span style="cursor: hand"><img
											src="../images/search.gif" width="51" height="23"
											align="absmiddle" onClick="document.forms[0].submit();" /> </span>
								</td>
							</tr>
							<tr align="left">
								<td bgcolor="#faf9f5" height="40">
					<table width="100%" border="0" cellspacing="0" cellpadding="0"
						style="border-top: 1px C1A156">
						<tr>
							<td>
								&nbsp;&nbsp;&nbsp;
								<span style="cursor:hand"><img src="../images/anniu_15.jpg" width="51" height="23" 
								     onClick="add()"/></span>
								&nbsp;
								<span style="cursor:hand"><img src="../images/anniu_17.jpg" onClick="deleteArticles()"
									width="51" height="23" /></span>
							</td>
							<td height="25" align="right" style="">
								总共
								<s:property value="%{allPageSize}" />
								条,每页显示
								<s:property value="%{pageSize}" />
								条,当前第
								<s:if test="maxPage==0">
            0/0页
            </s:if>
								<s:else>
									<s:property value="%{currPage+1}" />/<s:property
										value="%{maxPage}" />页</s:else>
								<A href="javascript:goUrl(<s:property value="%{0}"/>)">首页</A> |
								<A href="javascript:goUrl(<s:property value="%{prvPage}"/>)">上页</A>
								|
								<A href="javascript:goUrl(<s:property value="%{nextPage}"/>)">下页</A>
								|
								<A href="javascript:goUrl(<s:property value="%{maxPage}"/>)">尾页</A>&nbsp;
							</td>
						</tr>
					</table>
				</td>							
							</tr>
							<tr>
								<td valign="top" align="center">
									<table width="98%" border="0" cellpadding="1" cellspacing="1"
										id="listTable" class="tab_1">
										<tr align="left">
											<td width="6%" height="28" align="center"
												background="../images/tabbg.gif" nowrap="nowrap">
												<input type="checkbox" value="AllSelect" name="AllBox"
													id="AllBox" title="全选" onClick="selectAll(this)" />
												全选
											</td>
											<td width="3%" align="center"
												background="../images/tabbg.gif">
												ID
											</td>
											<td width="20%" align="center"
												background="../images/tabbg.gif">
												用户名
											</td>
											<td width="20%" align="center"
												background="../images/tabbg.gif">
												昵称
											</td>
											<td width="20%" align="center"
												background="../images/tabbg.gif">
												注册时间
											</td>
										 	<td width="12%" align="center"
												background="../images/tabbg.gif">
												设备数
											</td>
											<td width="20%" align="center"
												background="../images/tabbg.gif">
												操作
											</td>
										</tr>
										<s:iterator value="pages" status="stat">
											<s:if test="#stat.odd == true">
												<tr class="even" align="center"
													onMouseOver="this.className='myover'"
													onMouseOut="this.className='even'">
											</s:if>
											<s:else>
												<tr class="odd" align="center"
													onMouseOver="this.className='myover'"
													onMouseOut="this.className='odd'">
											</s:else>
											<TD align="middle">
												<INPUT id="<s:property value='id'/>" type="checkbox"
													onclick="checkBox();"
													value="<s:property value='id'/>" name="singleBox" />
											</TD>
											<td align="left" height="25">
												<a href="javascript:update(<s:property value="id" />);">
													<s:property value='id' />
												</a>
											</td>
											<td align="left" height="25">
												<a href="javascript:update(<s:property value="id" />);">
													<s:property value='username' />
												</a>
											</td>
											<td align="center" height="25">
												<a href="javascript:update(<s:property value="id" />);">
												<s:property value='nickname' />
												</a>
											</td>
											<td align="center" height="25">
												<a href="javascript:update(<s:property value="id" />);">
												<s:date name="createTime" format="yyyy-MM-dd"/>
												</a>
											</td>
											<td align="center" height="25">
												<a href="javascript:update(<s:property value="id" />);">
												<s:property value='sdevices.size' />
												</a>
											</td>
											<td align="center" height="25">
												<a href="javascript:deleteId(<s:property value="id" />);">删除</a>|<a href="javascript:update(<s:property value="id" />);">修改</a>
											</td>
											</tr>
										</s:iterator>
										<tr>
											<td height="25" align="right" style="" colspan="7">
												总共
												<s:property value="%{allPageSize}" />
												条,每页显示
												<s:property value="%{pageSize}" />
												条,当前第
												<s:if test="maxPage==0">
            0/0页
            </s:if>
												<s:else>
													<s:property value="%{currPage+1}" />/<s:property
														value="%{maxPage}" />页</s:else>
												<A href="javascript:goUrl(<s:property value="%{0}"/>)">首页</A>
												|
												<A href="javascript:goUrl(<s:property value="%{prvPage}"/>)">上页</A>
												|
												<A
													href="javascript:goUrl(<s:property value="%{nextPage}"/>)">下页</A>
												|
												<A href="javascript:goUrl(<s:property value="%{maxPage}"/>)">尾页</A>&nbsp;
											</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
			</div>
			</form>
			<div style="clear: both;"></div>
			<div style="height: 40px;" ></div>
			<s:include value="/common/footer.jsp"></s:include>
		</div>
		
	</body>
</html>